<?php
// 设置错误报告
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// 主页面模板 - 所有页面的基础结构
defined('BASE_PATH') or define('BASE_PATH', __DIR__ . '/');
// 加载配置
$config = require BASE_PATH . '/config/config.php';
$pageConfig = require BASE_PATH . '/config/pages.php';
$navigation = require BASE_PATH . '/config/navigation.php';
include_once BASE_PATH . '/includes/components.php';
// 定义路径常量
define('FRAGMENTS_PATH', $config['paths']['fragments']);
define('ASSETS_PATH', $config['paths']['assets']);

// 加载碎片映射表
$fragmentMap = require FRAGMENTS_PATH . 'index.php';
// 获取主题配置（如果有）
$themeConfig = [];
$themeFile = __DIR__ . '/themes/' . ($pageConfig['theme'] ?? 'default') . '/config.php';
if (file_exists($themeFile)) {
    $themeConfig = require $themeFile;
    if(isset($pageConfig['colors'])){
        $themeConfig['colors'] = array_merge($themeConfig['colors'], $pageConfig['colors']);
    }
}

// 定义获取组件配置的函数
function getComponentConfig($componentKey, $default = []) {
    global $pageConfig;
    return isset($pageConfig['components'][$componentKey]) ? $pageConfig['components'][$componentKey] : $default;
}

// 生成星级评分HTML (如果需要)
function generateStarRating($rating) {
    if (!is_numeric($rating)) return '';
    
    $html = '<div class="flex items-center">';
    for ($i = 1; $i <= 5; $i++) {
        $color = $i <= $rating ? 'text-yellow-400' : 'text-gray-300';
        $html .= "<i class='fa fa-star $color text-sm'></i>";
    }
    $html .= '</div>';
    return $html;
}

// 获取卡片样式类
function getCardStyleClass($style, $effect) {
    $baseClasses = 'rounded-xl overflow-hidden shadow-lg transition-all duration-300';
    
    switch ($effect) {
        case 'scale':
            $effectClass = 'transform hover:-translate-y-2 hover:shadow-xl';
            break;
        case 'elevation':
            $effectClass = 'hover:shadow-2xl';
            break;
        case 'border':
            $effectClass = 'border border-gray-200 hover:border-primary';
            break;
        default:
            $effectClass = '';
    }
    
    return $baseClasses . ' ' . $effectClass;
}
// 关于页 - 自动生成的页面文件
require __DIR__ . $pageConfig['template'] ?? '/templates/main.php';
?>
